<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="div">

        <h1 v-for="msg in msgs" v-on:click="greet(msg.name)">{{msg.name}}</h1>
    </div>
    <script src="../js/vue.js"></script>
    <script>
        var vm = new Vue({
            el: '#div',
            data: {
                msgs: []
            },
            mounted: {
            },
            methods:{
                greet:function(e){
                    console.log(e)
                },
                setMsg:function(e) {
                    this.msgs = e;
                },
                // Android需要调用的方法
               callJS: function (e){
                   var data = JSON.parse(e);
                   alert(data[0].name);
                   alert(data[1].name);
                   alert(data[2].name);
                   //vm.msgs = data 这种方式不行 数据不更新
                   vm.setMsg(data);//这种方式可以 数据会更新

                   let msg = {'name':'print','body':data};
                   alert(JSON.stringify(msg));//Android会监听alert
          }
            }
        })
    </script>
</body>

</html>
